package org.greatstorm.service;

import org.greatstorm.dao.ConfigDao;
import org.greatstorm.entity.Config;
import org.greatstorm.entity.EntityObject;
import org.greatstorm.util.GlobalVariables;

import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class ConfigManager {

	@Inject
	private ConfigDao configDao;

	public void initData() {
		EntityObject config = new EntityObject();
		config.put(Config.BLOG_TITLE, "XXX's Blog");
		config.put(Config.BLOG_SUBTITLE, "");
		config.put(Config.AMDIN_GMAIL, "");
		config.put(Config.PUBLIC, "welcome to XXX's Blog!");
		config.put(Config.ADMIN_URL, GlobalVariables.ADMIN_URL);
		config.put(Config.IS_ALLOW_REPLY, 1);
		config.put(Config.IS_ALLOW_REPLY_ANOMIMOUS, 1);
		config.put(Config.ARTICLE_RANK_LIST_COUNT, 10);
		config.put(Config.ARTICLE_PER_PAGE, 10);

		configDao.save(config);

	}

	public void deleteAll() {
		configDao.deleteAll();
	}

}
